using UnityEngine;

public class LeaderBoardUI : MonoBehaviour
{
	[SerializeField]
	private GameObject modeIcon;

	[SerializeField]
	private SelectableButtonController selectableButtonController;

	private GameTypePreviewInLeaderBoard _gameTypePreviewInLeaderBoard;

	private GameObject _previewMode;

	public GameTypePreviewInLeaderBoard GameTypePreviewInLeaderBoard
	{
		set
		{
			_gameTypePreviewInLeaderBoard = value;
		}
	}

	public void Show(SelectableButtonMode selectModeButton)
	{
		Init(selectModeButton);
	}

	private void Init(SelectableButtonMode selectModeButton)
	{
		_gameTypePreviewInLeaderBoard.ModeInfo = selectModeButton.ModeInfo;
		_gameTypePreviewInLeaderBoard.Init();
		_gameTypePreviewInLeaderBoard.SetLikePersent(selectModeButton.Percent);
		_gameTypePreviewInLeaderBoard.RefresfViewLikeBox();
		_gameTypePreviewInLeaderBoard.RefreshBonusAwardLabel();
		if (_previewMode != null)
		{
			Object.Destroy(_previewMode);
		}
		_previewMode = Object.Instantiate(selectModeButton.ModeInfo.GetAnimationPreview());
		_previewMode.transform.SetParent(modeIcon.transform);
		_previewMode.transform.localScale = Vector3.one;
		_previewMode.transform.localPosition = Vector3.zero;
		foreach (SelectableButton allButton in selectableButtonController.allButtons)
		{
			SelectableButtonTypeGameLeaderBoard selectableButtonTypeGameLeaderBoard = allButton as SelectableButtonTypeGameLeaderBoard;
			selectableButtonTypeGameLeaderBoard.TypeGame = selectModeButton.ModeInfo.typeGame;
			selectableButtonTypeGameLeaderBoard.Grid.GetComponent<LeaderBoardTypeGameUI>().Clear();
		}
		if (selectableButtonController.allButtons[0] != null)
		{
			selectableButtonController.allButtons[0].selected = false;
			selectableButtonController.allButtons[0].Select(true);
		}
	}
}
